package com.test.web.service.impl;

import com.test.web.dao.LoginDao;
import com.test.web.service.ILoginService;
import com.test.web.vo.UserVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * Created by caijiao on 2017/3/20.
 */
@Service
public class LoginServiceImpl implements ILoginService {
    @Resource
    private LoginDao loginDao;

    @Override
    public UserVo login(UserVo userEntity) {
        UserVo user = loginDao.login(userEntity);
        return user;
    }

    @Override
    public UserVo checkEmail(UserVo userEntity) {

        UserVo userEmail = loginDao.checkEmail(userEntity.getUserEmail());
        return userEmail;
    }

    @Override
    public void addUser(UserVo userVo) {
        long  bh=loginDao.queryId();
        int bhId=(int)bh;
        userVo.setUserId(bhId+1);
        loginDao.addUser(userVo);
    }

    @Override
    public void modifyUserMes(UserVo userVo) {
        if("1".equals(userVo.getSex())){
            userVo.setSex("女");
        }else{
            userVo.setSex("男");
        }
        loginDao.modifyUser(userVo);
    }
}
